<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>赛博朋克抽奖系统</title>
  <style>
    body {
      font-family: 'Courier New', monospace;
      background-color: #0d0d0d;
      color: #f0f0f0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      min-height: 100vh;
    }
    h1 {
      color: #ff00ff;
      text-shadow: 0 0 8px #ff00ff, 0 0 15px #00ffff;
    }
    /* 给九宫格加边框 */
    .grid-container {
      padding: 10px;
      border: 3px solid #00ffff;
      border-radius: 15px;
      display: inline-block;
    }
    .grid {
      display: grid;
      grid-template-columns: repeat(3, 100px);
      grid-template-rows: repeat(3, 100px);
      gap: 10px;
    }
    .cell {
      display: flex;
      align-items: center;
      justify-content: center;
      border: 2px solid #00ffff;
      border-radius: 8px;
      font-size: 16px;
      font-weight: bold;
      color: #fff;
      background: linear-gradient(145deg, #222, #111);
      box-shadow: 0 0 10px #00ffff inset;
      transition: 0.3s;
      text-align: center;
    }
    .cell.active {
      border-color: #ff00ff;
      box-shadow: 0 0 20px #ff00ff, 0 0 40px #00ffff inset;
    }
    button {
      background: #ff00ff;
      color: white;
      border: none;
      padding: 10px 20px;
      border-radius: 5px;
      font-size: 16px;
      cursor: pointer;
      margin: 10px;
      box-shadow: 0 0 10px #ff00ff, 0 0 20px #00ffff;
    }
    button:hover {
      background: #00ffff;
      color: #000;
    }
    #result {
      margin-top: 20px;
      font-size: 20px;
      text-shadow: 0 0 8px #00ffff;
    }
    #history {
      margin-top: 10px;
      font-size: 14px;
      color: #aaa;
    }
  </style>
</head>
<body>
  <h1>⚡ 九宫格抽奖 ⚡</h1>
  <div class="grid-container">
    <div class="grid" id="grid"></div>
  </div>
  <button id="startBtn">开始抽奖</button>
  <div id="result">结果：未开始</div>
  <div id="history">历史记录：</div>

  <script>
    const prizes = [
      {name:"能量饮料", price:12},
      {name:"赛博手环", price:88},
      {name:"霓虹耳机", price:199},
      {name:"虚拟货币", price:500},
      {name:"机械键盘", price:299},
      {name:"未来手套", price:150},
      {name:"芯片贴纸", price:20},
      {name:"LED面具", price:250}
    ];

    const grid = document.getElementById("grid");
    const result = document.getElementById("result");
    const history = document.getElementById("history");
    let cells = [];
    let timer = null;
    let current = 0;
    let running = false;

    function createGrid() {
      for (let i = 0; i < 9; i++) {
        const cell = document.createElement("div");
        cell.className = "cell";
        let prize;
        if (i === 4) {
          // 中间换成奖品，也加价格
          prize = {name:"神秘礼盒", price:999};
        } else {
          prize = prizes[i < 4 ? i : i - 1];
        }
        cell.innerHTML = `${prize.name}<br>￥${prize.price}`;
        grid.appendChild(cell);
        cells.push(cell);
      }
    }

    function startLottery() {
      if (running) return;
      running = true;
      let rounds = Math.floor(Math.random() * 20) + 30;
      let index = 0;
      timer = setInterval(() => {
        cells[current].classList.remove("active");
        current = (current + 1) % 8;
        if (current >= 4) current++;
        cells[current].classList.add("active");
        index++;
        if (index >= rounds) {
          clearInterval(timer);
          running = false;
          const prizeText = cells[current].innerHTML.replace("<br>", " - ");
          result.innerHTML = `🎉 你抽中了：${prizeText}`;
          history.innerHTML += `<div>获得：${prizeText}</div>`;
        }
      }, 120);
    }

    document.getElementById("startBtn").addEventListener("click", startLottery);
    createGrid();
  </script>
</body>
</html>
